<template>
  <div>
    <el-form ref="form" :model="form" label-width="120px" class="itemForm">
      <el-form-item label="用户ID">
        <el-input v-model="form.uid" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="find">查询</el-button>
        <el-button type="primary" @click="save">更新</el-button>
        <el-button type="danger" @click="del">删除</el-button>
      </el-form-item>

      <el-form-item label="体力">
        <el-input v-model="form.energy" />
      </el-form-item>

      <el-form-item label="饲料">
        <el-input v-model="form.feed" />
      </el-form-item>

      <el-form-item label="金币数">
        <el-input v-model="form.gold" />
      </el-form-item>

      <el-form-item label="最高金币数">
        <el-input v-model="form.hGold" />
      </el-form-item>

      <el-form-item label="动物">
        <el-input v-model="form.animal" />
      </el-form-item>

      <el-form-item label="prop">
        <el-input v-model="form.prop" />
      </el-form-item>
      <pre>
        PropBuy                = "buy"      // 购买动物次数
        PropSell               = "sell"     // 卖出动物次数
        PropExp                = "exp"      // 经验值
        PropFloatReward        = "fReward"  // 浮窗奖励
        PropExchange           = "exchange" // 兑换次数
        PropExchangeGoodsOrder = "eGOrder"  // 兑换次数
        PropInvite             = "invite"   // 邀请次数
        PropBagGotAnimal       = "bGAnimal" // 仓库 获得动物次数
        PropBagChooseAnimal    = "bCAnimal" // 仓库 获得动物次数
        PropRedPacket          = "rPacket"  // 红包数量
      </pre>

      <el-form-item label="每日事件">
        <el-input v-model="form.dailyEvent" />
      </el-form-item>
      <pre>
        DayFeedStorage              = "fStorage"  // 每日存多少水
        DayAskJigsaw                = "aJigsaw"   // 请求成功次数
        DayRewardJigsaw             = "rJigsaw"   // 兑换次数
        DayLuckJigsaw               = "lJigsaw"   // 幸运碎片兑换次数
        DayRewardShareFriend        = "rSFriend"  // 定向分享奖励
        DayRewardShareFriendBig1    = "rSFBig1"   // 定向分享奖励
        DayRewardShareFriendBig2    = "rSFBig2"   // 定向分享奖励
        DayBuyAnimalVideo           = "bAVideo"   // 定向分享奖励
        DayStealPre                 = "steal:"    // 偷取前缀
        DayEatShit                  = "eShit"     // 偷吃屎
        DayExchangeOrder            = "eOrder"    // 兑换商品订单
        DaySpeedUp                  = "sUp"       // 使用加速棒次数
        DayHelpFillPkg              = "hFPkg"     // 订单 帮助填箱
        DayHelpFillOnePkg           = "hFOPkg"    // 订单 帮助某个好友填箱
        DayFillPkgByFriend          = "fPBFriend" // 订单 被帮助填箱
        DayBagFree                  = "bFree"     // 仓库 免费领取
        DayRedPacket                = "rPacket"   // 红包 喂饲料获取
        DayVideoRedPacket           = "vRPacket"  // 红包 喂饲料获取
      </pre>

      <el-form-item label="产出（鸡蛋，羊毛，牛奶）">
        <el-input v-model="form.output" />
      </el-form-item>

      <el-form-item label="分享分数">
        <el-input v-model="form.sScore" />
      </el-form-item>

      <el-form-item label="碎片">
        <el-input v-model="form.jigsaw" />
      </el-form-item>

      <el-form-item label="昨日饲料">
        <el-input v-model="form.lastStorageFeed" />
      </el-form-item>

      <el-form-item label="今日饲料">
        <el-input v-model="form.todayStorageFeed" />
      </el-form-item>

      <el-form-item label="动态">
        <el-input v-model="form.msg" />
      </el-form-item>

      <el-form-item label="成语等级">
        <el-input v-model="form.lvl" />
      </el-form-item>

      <el-form-item label="成语提示">
        <el-input v-model="form.tipCnt" />
      </el-form-item>

      <el-form-item label="stat">
        {{ form.stat }}
      </el-form-item>

      <el-form-item label="用户名">
        {{ form.name }}
      </el-form-item>

      <el-form-item label="用户openId">
        {{ form.oId }}
      </el-form-item>

      <el-form-item label="用户头像">
        {{ form.hImg }}
      </el-form-item>

      <el-form-item label="邀请上级">
        {{ form.iUid }}
      </el-form-item>

      <el-form-item label="详细数据">
        <json-view :data="form" />
      </el-form-item>

    </el-form>
  </div>
</template>

<script>
import { userInfo, updateUser, delAccount } from '@/api/player'
import jsonView from 'vue-json-views'

export default {
  name: 'Level',
  components: {
    jsonView
  },
  data() {
    return {
      form: {
        uid: 0,
        name: '',
        oId: '',
        isAuth: false,
        hImg: '',
        lvl: 0,
        openLvl: false,
        iUid: 0,
        energy: 0,
        sScore: 0,
        output: '',
        feed: 0,
        gold: 0,
        hGold: 0,
        animal: '',
        prop: '',
        dailyEvent: '',
        msg: '',
        lastUEnergyT: 0,
        diamond: 0,
        tipCnt: 0,
        aLGrade: 0,
        aLDiff: 0,
        stat: '',
        version: '',
        lastStorageFeed: 0,
        todayStorageFeed: 0,
        jigsaw: []
      }
    }
  },
  methods: {

    find() {
      console.log(this.form.uid)
      userInfo({
        uid: this.form.uid
      }).then(response => {
        console.log(response)
        this.form = response.data.player
        this.form.dailyEvent = response.data.dailyEvent
        this.form.lastStorageFeed = response.data.lastStorageFeed
        this.form.todayStorageFeed = response.data.todayStorageFeed
        this.$forceUpdate()
        this.$message({ message: '更新数据成功！', type: 'success' })
      })
    },

    save() {
      updateUser({
        uid: this.form.uid,
        level: this.form.lvl,
        energy: this.form.energy,
        feed: this.form.feed,
        gold: this.form.gold,
        hGold: this.form.hGold,
        animal: this.form.animal,
        dailyEvent: this.form.dailyEvent,
        output: this.form.output,
        msg: this.form.msg,
        tipCnt: this.form.tipCnt,
        diamond: this.form.diamond,
        jigsaw: this.form.jigsaw,
        sScore: this.form.sScore,
        prop: this.form.prop,
        lastStorageFeed: this.form.lastStorageFeed,
        todayStorageFeed: this.form.todayStorageFeed
      }).then(response => {
        // this.$message({ message: '修改成功！', type: 'success' })
        this.find()
      })
    },

    del() {
      delAccount({
        uid: this.form.uid
      }).then(response => {
        this.$message({ message: '删除成功！', type: 'success' })
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.itemForm {
  margin: 30px;
  width: 800px;
}

.allItems {
  width: 800px;
  height: 48px;
}

.items {
  margin: 20px;
}

.item {
  float: left;
  margin: 2px;
}

.item-content {
  display: block;
  width: 16px;
  height: 16px;
}

.none {
  border: 1px solid #ebeef5;
}

.show {
  background-color: burlywood;
}

.hide {
  background-color: burlywood;
}

.text {
  font-size: 14px;
}

.itemIdiom {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  margin-left: 30px;
  width: 480px;
}
</style>
